package com.tuozixuan.flink.demo;

import java.util.Properties;

import org.apache.flink.streaming.api.TimeCharacteristic;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class AverageSensorReadingsSourceKafka {

	public static void main(String[] args) {

		Properties properties = new Properties();
		properties.setProperty("bootstrap.servers", "localhost:9092");
		properties.setProperty("group.id", "consumer-group");
		properties.setProperty(
		  "key.deserializer",
		  "org.apache.kafka.common.serialization.StringDeserializer"
		);
		properties.setProperty(
		  "value.deserializer",
		  "org.apache.kafka.common.serialization.StringDeserializer"
		);
		properties.setProperty("auto.offset.reset", "latest");
		StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
		env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
		env.setParallelism(1);
//		DataStream<String> stream = env
//		  // source为来自Kafka的数据，这里我们实例化一个消费者，topic为hotitems
//		  .addSource(
//		    new FlinkKafkaConsumer011<String>(
//		      "hotitems",
//		      new SimpleStringSchema(),
//		      properties
//		    )
//		  );

	}

}
